package com.wzy.netty.core.buf;

import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import io.netty.util.CharsetUtil;

/**
 * 描述  :
 * 创建人:    Wzy
 * 创建时间: 2020-06-11  16:45
 */
public class NettyByteBuf02 {
    public static void main(String[] args) {
        ByteBuf buf = Unpooled.copiedBuffer("银鞍照白马,飒踏如流星", CharsetUtil.UTF_8);
        if (buf.hasArray()) {
            byte[] content = buf.array();
            System.out.println(new String(content, CharsetUtil.UTF_8).trim());
        }
        int len = buf.readableBytes();
        System.out.println("可读长度=" + len);
        System.out.println(buf.getCharSequence(0, 15, CharsetUtil.UTF_8));
        
    }
}
